unit SeriTekrarBulma;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, FormClass, StdCtrls, ExtCtrls, XPMan, StdActns, ActnList,
  Buttons;

type
  TfmSeriTekrarBulma = class(TfmFormClass)
    Panel1: TPanel;
    LL: TLabel;
    MM: TMemo;
    Panel2: TPanel;
    Panel3: TPanel;
    L5: TLabel;
    M5: TMemo;
    Panel4: TPanel;
    L2: TLabel;
    M2: TMemo;
    btBul: TBitBtn;
    Panel5: TPanel;
    L4: TLabel;
    M4: TMemo;
    Panel6: TPanel;
    L3: TLabel;
    M3: TMemo;
    Panel7: TPanel;
    L1: TLabel;
    M1: TMemo;
    btTemizle: TBitBtn;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure btBulClick(Sender: TObject);
    procedure MMChange(Sender: TObject);
    procedure btTemizleClick(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fmSeriTekrarBulma: TfmSeriTekrarBulma;

implementation

{$R *.dfm}

procedure TfmSeriTekrarBulma.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
  Action := caFree;
  fmSeriTekrarBulma := nil;
end;

procedure TfmSeriTekrarBulma.btBulClick(Sender: TObject);
var
  SeriNo: string;
begin
  inherited;
  while MM.Lines.Count > 0 do
  begin
    Application.ProcessMessages;
    SeriNo := Trim(MM.Lines.Strings[0]);
    if M5.Lines.IndexOf(SeriNo) = -1 then
      if M4.Lines.IndexOf(SeriNo) <> -1 then
      begin
        M4.Lines.Delete(M4.Lines.IndexOf(SeriNo));
        M5.Lines.Add(SeriNo);
      end
      else
        if M3.Lines.IndexOf(SeriNo) <> -1 then
        begin
          M3.Lines.Delete(M3.Lines.IndexOf(SeriNo));
          M4.Lines.Add(SeriNo);
        end
        else
          if M2.Lines.IndexOf(SeriNo) <> -1 then
          begin
            M2.Lines.Delete(M2.Lines.IndexOf(SeriNo));
            M3.Lines.Add(SeriNo);
          end
          else
            if M1.Lines.IndexOf(SeriNo) <> -1 then
            begin
              M1.Lines.Delete(M1.Lines.IndexOf(SeriNo));
              M2.Lines.Add(SeriNo);
            end
            else
              M1.Lines.Add(SeriNo);

    MM.Lines.Delete(0);
  end;
end;

procedure TfmSeriTekrarBulma.MMChange(Sender: TObject);
var
  Lbl: string;
begin
  inherited;
  Lbl := StringReplace((Sender as TMemo).Name, 'M', 'L', [rfReplaceAll]);
  (FindComponent(Lbl) as TLabel).Caption := IntToStr((Sender as TMemo).Lines.Count);
end;

procedure TfmSeriTekrarBulma.btTemizleClick(Sender: TObject);
begin
  inherited;
  MM.Clear;
  M1.Clear;
  M2.Clear;
  M3.Clear;
  M4.Clear;
  M5.Clear;
end;

procedure TfmSeriTekrarBulma.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
//  inherited;

end;

end.

